#!/bin/bash

base_path="$(dirname $1)"
base_filename_ext="$(basename $1)"
lab_name="${base_filename_ext%.sh*}"

# todo: is $lab_name with the pattern "labX"?
cast_filename="${base_path}/${lab_name}.cast"

if test -f "${cast_filename}" ; then
	asciinema rec -e "" --stdin --append -c "vim $@" ${cast_filename}
else
	asciinema rec -e "" --stdin -c "vim $@" ${cast_filename}
fi

